package com.ruoyi.lxzx.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.lxzx.domain.UserAttentList;
import com.ruoyi.lxzx.domain.UserAttentSearch;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.lxzx.domain.UserAttent;
import com.ruoyi.lxzx.service.IUserAttentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 关住Controller
 * 
 * @author ruoyi
 * @date 2024-10-26
 */
@RestController
@RequestMapping("/lxzx/attent")
public class UserAttentController extends BaseController
{
    @Autowired
    private IUserAttentService userAttentService;

    /**
     * 查询关住列表
     */
    @PreAuthorize("@ss.hasPermi('lxzx:attent:list')")
    @GetMapping("/list")
    public TableDataInfo list(UserAttentSearch search)
    {
        startPage();
        List<UserAttentList> list = userAttentService.selectUserAttentList(search);
        return getDataTable(list);
    }


    /**
     * 获取关住详细信息
     */
    @PreAuthorize("@ss.hasPermi('lxzx:attent:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(userAttentService.selectUserAttentById(id));
    }

    /**
     * 新增关住
     */
    @PreAuthorize("@ss.hasPermi('lxzx:attent:add')")
    @Log(title = "关住", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserAttent userAttent)
    {
        return toAjax(userAttentService.insertUserAttent(userAttent));
    }

    /**
     * 修改关住
     */
    @PreAuthorize("@ss.hasPermi('lxzx:attent:edit')")
    @Log(title = "关住", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserAttent userAttent)
    {
        return toAjax(userAttentService.updateUserAttent(userAttent));
    }

    /**
     * 删除关住
     */
    @PreAuthorize("@ss.hasPermi('lxzx:attent:remove')")
    @Log(title = "关住", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(userAttentService.deleteUserAttentByIds(ids));
    }
}
